#include <modules\graphics\entity_pose.h>

namespace DelGE
{
	namespace Modules
	{
		namespace Graphics
		{
			EntityPose::EntityPose()
			{
				this->vModelPoseList = vector<ModelPose*>();
			}
			
			EntityPose::EntityPose(EntityPose *pPose)
			{
				// Copy all the models in the pose
				for (int iModelPoseIndex = 0; iModelPoseIndex < pPose->GetModelPoseCount(); iModelPoseIndex ++)
				{
					this->AddModelPose(new ModelPose(pPose->GetModelPose(iModelPoseIndex)));
				}
			}

			EntityPose::~EntityPose()
			{
				for (unsigned int iModelIndex = 0; iModelIndex < this->vModelPoseList.size(); iModelIndex ++)
					delete this->vModelPoseList[iModelIndex];

				this->vModelPoseList.clear();
			}

			void EntityPose::AddModelPose(ModelPose* pModelPose)
			{
				this->vModelPoseList.push_back(pModelPose);
			}
			
			void EntityPose::RemoveModelPose(int iIndex)
			{
				if (iIndex < this->GetModelPoseCount())
				{
					delete this->vModelPoseList[iIndex];
					this->vModelPoseList.erase(this->vModelPoseList.begin() + iIndex);
				}
			}

			ModelPose* EntityPose::GetModelPose(int iIndex)
			{
				if ((iIndex < 0) || (iIndex >= (int)this->vModelPoseList.size())) return NULL;

				return this->vModelPoseList[iIndex];
			}

			int EntityPose::GetModelPoseCount()
			{
				return this->vModelPoseList.size();
			}
		}
	}
}
